package com.yhz.openapi.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 统一返回数据类型
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ResponseResult<T> {
    private boolean status;
    private String msg;
    private T t;

    /**
     * 成功响应的信息
     */
    public static ResponseResult getSuccess(){
        return new ResponseResult(true,null,null);
    }
    public static ResponseResult getSuccess(String msg){
        return new ResponseResult(true,msg,null);
    }
    public static <T> ResponseResult getSuccess(T t){
        return new ResponseResult(true,null,t);
    }
    public static <T> ResponseResult getSuccess(String msg,T t){
        return new ResponseResult(true,msg,t);
    }

    /**
     * 失败响应的信息
     */
    public static ResponseResult getFail(){
        return new ResponseResult(false,null,null);
    }
    public static ResponseResult getFail(String msg){
        return new ResponseResult(false,msg,null);
    }
    public static <T> ResponseResult getFail(T t){
        return new ResponseResult(false,null,t);
    }
    public static <T> ResponseResult getFail(String msg,T t){
        return new ResponseResult(false,msg,t);
    }
}
